<template>
	<view class="updatefriends">
		<view class="m_header_top">
			<my-top @back='back' title="修改亲信息":isback="true"   :isline='true'>
				<template slot="quit">
					<view  class="quits">取消</view>
				</template >
				<template slot="save">
					<view class="submittop">
						保存
					</view>
				</template>
			</my-top>
		</view>
		<!-- <view class=""></view> -->
		<view class="mylist">
			<view class="myitem" @click="changereation">
				<view class="title">
					与宝宝关系
				</view>
				<view class="dist">
					<text class="name">{{userdata.name}}</text>
					<text class="iconfont todaygengduo"></text>
				</view>
			</view>
			<view class="myitem" @click="editnickname">
				<view class="title">
					昵称
				</view>
				<view class="dist">
					<text class="name">{{userdata.nickname}}</text>
					<text class="iconfont todaygengduo"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapGetters,
		mapMutations
	} from 'vuex';
	export default {
		data(){
			return {
				childId:'',
				userdata:{
					relationId:'',
					name:'',
					nickname:'',
				}
			}
		},
		onLoad(e){
			console.log(e.childInfo)
			this.childId = e.childId;
			if(e.name){
				this.userdata.nickname = e.name
			}
			if(e.childId){
				console.log(this.childId);
				this.initval(e.childId)
			}
		},
		onShow() {
			let checkrelation =  uni.getStorageSync('checkrelation');
			console.log('checkrelation',checkrelation)
			if(checkrelation){
				this.userdata.name =checkrelation.name;
				this.userdata.relationId =checkrelation.code;
			}
		},
		methods:{
			...mapActions({
				getIdSchedule:'initData/getIdSchedule',
				// delRoleRegulateTb:'initData/delRoleRegulateTb',
			}),
			async initval(val){
				let data= await this.getIdSchedule(val);
				console.log(data,'小孩数据');
				if(data && data.name){
					this.userdata.relationId = data.relationId;
					this.userdata.nickname = data.name;
					this.userdata.name = data.relationName;
				}
			},
			back(){
				uni.redirectTo({
					url:'./editfriends'
				})
			},
			editnickname(){
				let obj = {
					name:this.userdata.nickname,
					url:'/pages/template/addEditCalendar/editfriends/update'
				}
				uni.navigateTo({
					url:'../nickname/nickname?data='+JSON.stringify(obj) 
				})
			},
			changereation(){
				let obj = {
					id:20,
					code: this.userdata.relationId,
					url:'/pages/template/addEditCalendar/editfriends/update'
				}
				console.log(obj)
				uni.navigateTo({
					url:'../addrelation/addrelation?data='+JSON.stringify(obj)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.updatefriends{
		.mylist{
			// margin-top:24rpx;
			// padding: 0 16rpx;
			display: flex;
			flex-direction: column;
			.dist{
			display: flex;
			align-items: center;
				.name{
					margin-right: 16rpx;
					
				}
				.todaygengduo{
					font-size: 44rpx;
				}
			}
			.myitem{
				margin-bottom: 4rpx;
				height: 100rpx;
				background-color: #FFFFFF;
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding:  0 32rpx;
			}
		}
		.quits{
			width: 68rpx;
			height: 48rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			line-height: 54rpx;
			color: #999999;
			opacity: 1;

		}
		.submittop{
			width: 132rpx;
			height: 60rpx;
			border-radius: 30rpx;
			background-color: rgba(4, 161, 251, 1);
			text-align: center;
			line-height: 60rpx;
			color: #FFFFFF;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: 500;
		}
	}
</style>
